package com.xoa.controller.workflow;

import com.xoa.model.workflow.FlowSort;
import com.xoa.model.workflow.FlowTypeModel;
import com.xoa.service.workflow.flowSort.FlowSortService;
import com.xoa.util.ToJson;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * Created by gsb on 2017/7/18.
 */
@Controller
@RequestMapping("/flowSort")
public class FlowSortController {

    @Resource
    private FlowSortService flowSortService;


    /**
     * 创建作者:   张航宁
     * 创建日期:   2017/7/18
     * 方法介绍:   获取一级菜单下的所有流程信息
     * @return
     */
    @ResponseBody
    @RequestMapping("/getFlowTypes")
    public ToJson<FlowSort> getFlowTypes(HttpServletRequest request,@RequestParam(required = false) String sonType){
        if(sonType!=null&&sonType.equals("1")){
            return flowSortService.getSonFlowTypes();
        }
        return flowSortService.getFlowTypes();
    }

    /**
     * 按层级获取流程分类
     * @return
     */
    @ResponseBody
    @RequestMapping("/getSortAndType")
    public ToJson<FlowSort> getSortAndType(){
        return flowSortService.getSortAndType();
    }


    /**
     * 判断类型是否为公文
     */
    @RequestMapping("/selectType")
    @ResponseBody
    public ToJson<FlowSort> selectType(HttpServletRequest request, Integer flowId){
        return flowSortService.selectType(request,flowId);
    }

}
